<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>星月</title>
<link rel="stylesheet" href="./bootstrap-3.4.1-dist/css/bootstrap.css">
<script src="./jquery-3.5.1.min.js"></script> <!-- 也可以引用自己下载的jquery库 -->
		<style>
      #msg{
    height: 2rem;
    text-align: center;
    position: fixed;
    top: 50%;
    margin-top: -1rem;
    line-height: 2rem;
    width: 100%;
}
#msg span{
    color: #fff;
    background: #f05f55;
    height: 2rem;
    display: inline-block;
    padding: 0 3rem;
    border-radius: 52px;
}
			.loading {
				width: 10%;
				height: 10%;
				position: fixed;
				top: 1000px;
				left:150px;
				
				z-index: 100;
			}
.loading img {
                width: 700px;
                height: 700px;
            }
.zhuce_body .login_kuang .zc .bj_bai {
position:relative
  float: left;
  width: 380px;
  height: 340px;
backdrop-filter:blur(55px);
border-radius:15px;
box-shadow: 10px 10px 5px rgb(108, 147, 219);
 
  background: #FFF;
 margin:  0 auto;
}
.zhuce_body .login_kuang .zc .bj_bai .zhuc {
 margin: 15px;
}
.yq{
display:inline;
margin-top:50px;
position:absolute;
bottom:-292px;
left:30px;
}
		</style>
 
		
<script>
        function alert(e){
            $("body").append("<div id='msg'><span>"+e+"</span></div>");
            clearmsg();
        }
        function clearmsg(){
            var t = setTimeout(function(){
                $("#msg").remove();
            },2000)
        };
        
       </script>
    <script>
        function check() {
            var username=document.getElementById("_username").value;
            var password=document.getElementById("_password").value;
            var checkCode=document.getElementById("code").value;
            if(!username){
                alert("账号不能为空");
                return false;
            }
            if(!password){
           alert("密码不能为空");
               
                return false;
            }
            if(!checkCode){
                alert("验证码不能为空");
                return false;
            }
        }
}else{
return
}
}
    </script>
</head>
<body>
<?php
session_start();//在最顶端，不要bai有输出
$_SESSION['username']='username';//直接把用户名abc赋予dutest
header("content-type:text/html;charset=utf-8");
$loginSingal="";
//连接数据库
if($_SERVER["REQUEST_METHOD"]=="POST") {     //表单post提交后执行的代码，避免变量不存在的错误
   include('config.php');
    if (!$link) {
        die("连接失败: " . mysqli_connect_error());
    }
    if (isset($_POST)) {

        //判断验证码是否填写并且是否正确
        if ($_POST['code'] != $_SESSION['VCODE']) {
                $loginSingal="<script>alert('验证码不正确！');</script>";
            }else{
            $sql = "select * from user where username = '{$_POST['username']}' and password='{$_POST['password']}'";
            $rs = mysqli_query($link, $sql); //执行sql查询
            $row = mysqli_fetch_assoc($rs);
    
            if ($row) { // 用户存在；
                if ($_POST['username'] == $row['username'] && $_POST['password'] == $row['password']) { //对密码进行判断。
                    $loginSingal="<script>alert('登陆成功！<--".$row['nicheng']."-->欢迎回来~');</script>";
                    $_SESSION['id']= $row['id'];//直接把用户名abc赋予dutest
                    $_SESSION['username']= $row['username'];//直接把用户名abc赋予dutest
                    $_SESSION['nicheng']= $row['nicheng'];//直接把用户名abc赋予dutest
                    $_SESSION['img']= $row['img'];//直接把用户名abc赋予dutest
                    header("refresh:0.5;url=main.php");//一秒后登录到主页
                }
            } else {
                $loginSingal="<script>alert('账号或密码错误！');</script>";

            }
        }

    }

}
?>
	<meta name="keywords" content="盒老师">
	<meta name="content" content="盒老师">
    <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
    <link type="text/css" rel="stylesheet" href="css/login.css">
    <script type="text/javascript" src="js/jquery-1.8.0.min.js"></script>
   
</head>
<div class="loading">
			<!-- 这里是自由发挥的空间，可以用canvas或者img -->
            
		</div>
<body class="login_bj" >
<div class="zhuce_body">
	<div class="logo"><a href="#"><img src="images/logo.png" width="114" height="54" border="0"></a></div>
    <div class="zhuce_kong login_kuang">
    	<div class="zc">
        	<div class="bj_bai">
            <h3>星月信息管理系统</h3>
            <form action="" method="post">
        <p><input type="text" class="kuang_txt" placeholder="请输入登录账号"
                  autocomplete="off" name="username" id="_username" tabindex="1"/></p>
        <p><input type="password" class="kuang_txt"
                  placeholder="请输入密码" autocomplete="off" name="password" id="_password" tabindex="2"/></p>
        <p>
            <span>
            <input type="text" name="code" id="code"
                   class="kuang_txt"  placeholder="验证码" autocomplete="off" tabindex="3"/>
            <img src="code.php" style="position: relative;top: 5px "
                 onClick="this.src='code.php?nocache='+Math.random()" style="cursor:hand">
        </span>
<p class="zhuc">没有账号？<a href="index.php">立即注册</a></p>
        </p>
                
                <!-- <input name="登录" type="button" class="btn_zhuce" value="登录"> -->
                <?php echo $loginSingal; ?>
                <p><button class="btn_zhuce" onclick="return check()">登录</button></p>
                
            </form>
            </div>
        	<p class="yq">本站服务器由<a href="https://idc.leidian6.cn" target="_blank">
<img src="https://www.leidianyun.cn/Uploads/2021-06-11/60c387548b2a0.jpg" style="height: 50px" alt="Rob Roy Glacier">
</a>提供服务<br>本站安全由<a href="https://idc.leidian6.cn" target="_blank">
<img src="https://www.leidianyun.cn/Uploads/2021-06-11/60c387548b2a0.jpg" style="height: 50px" alt="Rob Roy Glacier">
</a>提供防护</a></p>
       
</body>
</html>